import React from 'react';
import {useDispatch} from "react-redux";
import {getWeiboAsync, useGetSelector} from "../store/slice/weibo";

function PageList(props) {
    const dispatch = useDispatch()
    const {pageNo,pageSum} = useGetSelector()
    const pageArr = []
    for(let i = 1;i<=pageSum;i++){
        pageArr.push(<a key={i} href="" className={pageNo===i? "active":''} onClick={e=>{
            e.preventDefault()
            dispatch(getWeiboAsync(i))
        }}>{i}</a>)
    }
    return (
        <div className="page">
            {
                pageArr
            }
        </div>
    );
}

export default PageList;